package practice09;


public class Student extends Person{
//    再写一个Student类继承Person类，除了id，name，age属性，还有要有Klass属性。也有一个introduce方法，

//    但是Student的Klass属性不是一个数字，而是一个对象

    Klass klass;
    public Student(Integer id, String name, Integer age, Klass klass) {
        super(id,name,age);
        this.klass=klass;
    }
    public void setKlass(Klass klass) {
        this.klass = klass;
    }
    public Klass getKlass() {
        return klass;
    }


    private boolean isClassLeader() {
        Student classLeader =  klass.getLeader();
        return this.equals(classLeader);
    }

    //    introduce方法返回一个字符串形如：
//    My name is Tom. I am 21 years old. I am a Student. I am at Class 2.
    @Override
    public String introduce() {
        String words = super.introduce() + " I am a Student.";
        words += this.isClassLeader() ? " I am Leader of "+this.getKlass().getDisplayName()+".": " I am at "+this.getKlass().getDisplayName()+".";
        return words;
    }
}
